<template>
  <div class="search">
    <el-input v-model="searchText" placeholder="请输入关键字搜索" @keyup.enter.native="StartSearch">
      <i class="el-input__icon el-icon-search"></i>
      <el-button slot="append" icon="el-icon-search" @click="StartSearch"></el-button>
    </el-input>
  </div>
</template>

<script>
import QQMusic from "../utils/qqmusic";
var _this;
export default {
  name: "search",
  created() {
    _this = this;
  },
  data() {
    return {
      searchText: "",
      parent: null
    };
  },
  methods: {
    StartSearch() {
      var st = this.$data.searchText;
      if (st === "") {
        this.$alert("请输入关键字", "错误", {
          confirmButtonText: "确定"
        });
        return;
      }
      _this.parent.$refs.navMenu.activeIndex = "2";
      _this.parent.$refs.playList.aLoading = true;
      new QQMusic().search(st).then(res => {
        _this.parent.UpdateList(res);
      });
    }
  }
};
</script>

<style>
.search {
  -webkit-app-region: no-drag;
  float: left;
  padding-left: 20px;
  padding-top: 15px;
}
</style>